local ITEM_BREAD = 2689
local ITEM_GINGERBREADMAN = 6501
local ITEM_CAKE = 6278
local ITEM_CHOCOLATE_CAKE = 8847 
local ITEM_LUMP_OF_CHOCOLATE_DOUGH = 8846
local ITEM_CHOCOLATE_BAR = 6574
local ITEM_BAKING_TRAY = 2561
local ITEM_BAKING_TRAY_DOUGH = 8848
local ITEM_COOKIE = 2687

function onUse(cid, item, frompos, item2, topos)
if item.itemid == ITEM_LUMP_OF_CAKE_DOUGH and item2.itemid == ITEM_CHOCOLATE_BAR then
                          doPlayerAddItem( cid, ITEM_LUMP_OF_CHOCOLATE_DOUGH)
                          doRemoveItem(item.uid, 1)
                          doRemoveItem(item2.uid, 1)
                          return TRUE  
                          end
if item.itemid == ITEM_LUMP_OF_CAKE_DOUGH and item2.itemid == ITEM_BAKING_TRAY then
                          doPlayerAddItem( cid, ITEM_BAKING_TRAY_DOUGH)
                          doRemoveItem(item.uid, 1)
                          doRemoveItem(item2.uid, 1)
                          return TRUE  
                          end
if(isInArray(OVEN_ON, item2.itemid) == TRUE) then
		if(item2.actionid == 6783 and getPlayerStorageValue(cid, 6666) == 1) then
			if item.itemid == ITEM_LUMP_OF_CAKE_DOUGH then
				doCreateItem( ITEM_GINGERBREADMAN, 1, topos)
				doRemoveItem(item.uid, 1)
				return TRUE
			end
            end
		if(item.itemid == ITEM_DOUGH) then
			doCreateItem( ITEM_BREAD, 1, topos)
			doRemoveItem(item.uid, 1)
		elseif(item.itemid == ITEM_LUMP_OF_CAKE_DOUGH) then
			doCreateItem( ITEM_CAKE, 1, topos)
			doRemoveItem(item.uid, 1)
		elseif(item.itemid == ITEM_LUMP_OF_CHOCOLATE_DOUGH) then
			doCreateItem( ITEM_CHOCOLATE_CAKE, 1, topos)
			doRemoveItem(item.uid, 1)
		elseif(item.itemid == ITEM_BAKING_TRAY_DOUGH) then
                  doCreateItem( ITEM_COOKIE, 12, topos)
			doRemoveItem(item.uid, 1)

            end
	else
		doPlayerSendCancel(cid, 'Sorry, not possible.')
	end
	return TRUE
end